OpenGL render state. More...
#include <kanzi/core.ui/platform/graphics_backend/gl/gl_render_state.hpp>
Classes | |
class | RenderValueInfo |
Render value information. More... | |
union | RenderValueUnion |
Union containing one render value to be arranged into an array. More... | |
struct | TextureRenderValue |
Container for texture render value and the width/height uniforms. More... | |
Public Types | |
using | HandleType |
Type for handle identifiers into values in the render state. | |
Public Member Functions | |
void | attach (MaterialSharedPtr material) |
Attach to a certain material/node combination. | |
bool | bind (Renderer &renderer) |
Applies the render state the render state. | |
template<typename T > | |
void | fillDefaultValues (GlRenderState::HandleType handle, size_t startIndex, size_t endIndex) |
Fills a uniform array with default values. | |
optional< int > | getBlendModeValue () const |
Get blend mode value. | |
template<typename T > | |
size_t | getElementCount (GlRenderState::HandleType handle) const |
Gets the number of elements for given handle. | |
template<> | |
size_t | getElementCount (GlRenderState::HandleType handle) const |
GlRenderState::getElementCount() specialization. | |
template<typename T > | |
HandleType | getHandle (string_view name) |
Access handle by type. | |
template<> | |
GlRenderState::HandleType | getHandle (string_view name) |
GlRenderState::getHandle() specialization. | |
MaterialSharedPtr | getMaterial () const |
Gets the attached material. | |
template<> | |
TextureSharedPtr | getValue (GlRenderState::HandleType handle) const |
GlRenderState::getValue() specialization. | |
template<typename T > | |
T | getValue (HandleType handle) const |
Accesses a value by handle. | |
template<typename T > | |
T | getValue (HandleType handle, size_t index) const |
Accesses a value by handle. | |
GlRenderState () | |
Empty constructor. | |
template<> | |
bool | handleMatches (GlRenderState::HandleType handle, string_view name) const |
GlRenderState::handleMatches() specialization. | |
template<typename T > | |
bool | handleMatches (HandleType handle, string_view name) const |
Checks whether given handle matches the current render state. | |
bool | hasMaterial () const |
Returns whether the render state has a valid material. | |
void | reattach () |
Reattach already-attached material. | |
void | setBlendModeValue (optional< int > value) |
Sets the blend mode value. | |
template<typename T > | |
bool | setRange (GlRenderState::HandleType handle, AbstractRange &range) |
Specialized implementation for assigning range. | |
template<> | |
bool | setRange (GlRenderState::HandleType, AbstractRange &) |
GlRenderState::setRange() specialization. | |
template<> | |
bool | setRange (GlRenderState::HandleType, AbstractRange &) |
GlRenderState::setRange() specialization. | |
template<> | |
bool | setRange (GlRenderState::HandleType, AbstractRange &) |
GlRenderState::setRange() specialization. | |
template<> | |
bool | setRange (GlRenderState::HandleType, AbstractRange &) |
GlRenderState::setRange() specialization. | |
bool | setRange (HandleType handle, AbstractRange &range) |
Sets values of a render target array from a range. | |
bool | setRange (HandleType handle, AbstractRange *range) |
Sets values of a render target array from a range. | |
bool | setRange (HandleType handle, const AbstractRangeSharedPtr &range) |
Sets values of a render target array from a range. | |
template<typename T > | |
bool | setTypedValue (GlRenderState::HandleType handle, const Variant &value, size_t elementIndex) |
Sets a variant value. | |
template<typename T > | |
void | setValue (HandleType handle, const T &value) |
Wrapper for setting a render value by handle. | |
template<typename T > | |
void | setValue (HandleType handle, const T &value, size_t elementIndex) |
Set a render value identified by handle. | |
Protected Types | |
typedef vector< RenderValueInfo > | RenderValueInfoContainer |
Container for render value information. | |
typedef vector< RenderValueUnion > | RenderValueUnionContainer |
Container for render values. | |
typedef vector< TextureRenderValue > | TextureRenderValueContainer |
Container for texture render values. | |
Protected Member Functions | |
int | acquireUniformLocation (AbstractPropertyType propertyType) const |
Acquires uniform location wrapper. | |
int | acquireUniformLocation (string_view name) const |
Acquires uniform location from the attached material. | |
size_t | allocateValues (size_t count) |
Allocates values from value array. | |
HandleType | getHandle (PropertyDataType type, string_view name, size_t count) |
Accesses a handle by explicit information. | |
size_t | getUniformElementCount (AbstractPropertyType propertyType) const |
Get uniform element count wrapper. | |
size_t | getUniformElementCount (string_view name) const |
Gets the number of uniform elements in the attached material. | |
float * | getValueArrayFloat (HandleType handle, size_t elementIndex) |
Gets a reference into the value array (as floats). | |
int * | getValueArrayInt (HandleType handle, size_t elementIndex) |
Gets a reference into the value array (as integers). | |
void | setTypedValue (HandleType handle, bool value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, ColorRGBA value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, const Matrix3x3 &value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, const Matrix4x4 &value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, const SRTValue2D &value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, const SRTValue3D &value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, float value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, int value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, TextureSharedPtr value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, Vector2 value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, Vector3 value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, Vector4 value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
void | setTypedValue (HandleType handle, void *value, size_t elementIndex) |
Specialization for setting a value of specific type. | |
Static Protected Member Functions | |
template<typename T > | |
static size_t | getValueSize () |
Gets the size of a render value type. | |
template<> | |
size_t | getValueSize () |
GlRenderState::getValueSize() specialization. | |
template<> | |
size_t | getValueSize () |
GlRenderState::getValueSize() specialization. | |
template<typename T > | |
static PropertyDataType | getValueType () |
Gets the property type of a render value type. | |
Protected Attributes | |
optional< int > | m_blendModeValue |
Singular property value for blend mode. | |
RenderValueInfoContainer | m_infoArray |
Render value information structures. | |
MaterialSharedPtr | m_material |
Currently attached material. | |
TextureRenderValueContainer | m_textureArray |
Render texture values, contain textures within the array. | |
vector< RenderValueUnion > | m_valueArray |
Render value unions. | |
OpenGL render state.
Type for handle identifiers into values in the render state.
|
protected |
Container for render value information.
|
protected |
Container for render values.
|
protected |
Container for texture render values.
|
inlineexplicit |
Empty constructor.
Applies the render state the render state.
After calling this function, geometry can be rendered using the render state settings.
renderer | Renderer to use. |
void kanzi::GlRenderState::attach | ( | MaterialSharedPtr | material | ) |
Attach to a certain material/node combination.
material | Material to attach to. |
void kanzi::GlRenderState::reattach | ( | ) |
Reattach already-attached material.
Does nothing if no material attached.
|
inline |
Gets the attached material.
|
inline |
Returns whether the render state has a valid material.
|
inline |
Set a render value identified by handle.
The handle may be invalid (negative), in which case this function does nothing.
handle | Identifying handle. |
value | Value to set. |
elementIndex | Index of the element in the value to set. |
|
inline |
Wrapper for setting a render value by handle.
Element index is zero.
handle | Identifying handle. |
value | Value to set. |
|
inline |
Get blend mode value.
Sets the blend mode value.
value | Optional blend mode value. |
value
parameter changed from GraphicsBlendMode to optional<int>.
|
inline |
Access handle by type.
name | Value name. |
|
inline |
Gets the number of elements for given handle.
handle | Handle. |
|
inline |
Accesses a value by handle.
Handle must be valid, access with invalid handle is undefined behavior.
handle | Handle to value. |
index | Index of the value to access. |
|
inline |
Accesses a value by handle.
Index of the accessed value is zero.
handle | Handle to value. |
|
inline |
Checks whether given handle matches the current render state.
handle | Handle to check. |
name | Name to compare against. |
|
inline |
Sets a variant value.
If the value is not an exact match, tries to cast the value to T.
handle | The identifying handle. |
value | The variant value. |
elementIndex | The index of the array element. |
|
inline |
Fills a uniform array with default values.
handle | The identifying handle. |
startIndex | The start index for the fill operation. |
endIndex | The end index pointing to one after the last fill element. |
|
inline |
Specialized implementation for assigning range.
If the array is larger than the range, writes default values to the remaining values in the end of the array. You must validate the handle before calling this function.
handle | Valid handle from the render state. |
range | Range input. |
bool kanzi::GlRenderState::setRange | ( | HandleType | handle, |
AbstractRange & | range ) |
Sets values of a render target array from a range.
If the array is larger than the range, writes default values to the remaining values in the end of the array.
handle | Handle from the render state. |
range | Range input. |
range
parameter. bool kanzi::GlRenderState::setRange | ( | HandleType | handle, |
AbstractRange * | range ) |
Sets values of a render target array from a range.
If the array is larger than the range, writes default values to the remaining values in the end of the array. If the range is a nullptr, sets all the elements of the render target array to default values.
handle | Handle from the render state. |
range | Range input. |
|
inline |
Sets values of a render target array from a range.
If the array is larger than the range, writes default values to the remaining values in the end of the array. If the range is a nullptr, sets all the elements of the render target array to default values.
handle | Handle from the render state. |
range | Range input. |
|
protected |
Acquires uniform location from the attached material.
name | Name to query. |
|
inlineprotected |
Acquires uniform location wrapper.
propertyType | Property type to query. |
|
protected |
Gets the number of uniform elements in the attached material.
name | Name to query. |
|
inlineprotected |
Get uniform element count wrapper.
propertyType | Property type to query. |
|
inlineprotected |
Allocates values from value array.
count | Number of values to allocate. |
|
inlineprotected |
Accesses a handle by explicit information.
type | Value type. |
name | Value name. |
count | Number of values to allocate per element if new handle is required. |
|
inlineprotected |
Gets a reference into the value array (as integers).
Contents of the value are not guaranteed, it points directly to the memory block within a value array.
handle | Handle to value info. |
elementIndex | Index of the element for the render value, used only for error checking. |
|
inlineprotected |
Gets a reference into the value array (as floats).
Contents of the value are not guaranteed, it's pointing directly to the memory block within value array.
handle | Handle to value info. |
elementIndex | Index of the element for the render value, used only for error checking. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
inlineprotected |
Specialization for setting a value of specific type.
This version intentionally exists to throw an exception on an invalid call.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
|
protected |
Specialization for setting a value of specific type.
handle | Name. |
value | Value. |
elementIndex | Index of the element to set. |
Gets the size of a render value type.
|
inlinestaticprotected |
Gets the property type of a render value type.
GlRenderState::HandleType kanzi::GlRenderState::getHandle | ( | string_view | name | ) |
GlRenderState::getHandle() specialization.
bool kanzi::GlRenderState::handleMatches | ( | GlRenderState::HandleType | handle, |
string_view | name ) const |
GlRenderState::handleMatches() specialization.
TextureSharedPtr kanzi::GlRenderState::getValue | ( | GlRenderState::HandleType | handle | ) | const |
GlRenderState::getValue() specialization.
size_t kanzi::GlRenderState::getElementCount | ( | GlRenderState::HandleType | handle | ) | const |
GlRenderState::getElementCount() specialization.
|
staticprotected |
GlRenderState::getValueSize() specialization.
|
staticprotected |
GlRenderState::getValueSize() specialization.
bool kanzi::GlRenderState::setRange | ( | GlRenderState::HandleType | , |
AbstractRange & | ) |
GlRenderState::setRange() specialization.
bool kanzi::GlRenderState::setRange | ( | GlRenderState::HandleType | , |
AbstractRange & | ) |
GlRenderState::setRange() specialization.
bool kanzi::GlRenderState::setRange | ( | GlRenderState::HandleType | , |
AbstractRange & | ) |
GlRenderState::setRange() specialization.
bool kanzi::GlRenderState::setRange | ( | GlRenderState::HandleType | , |
AbstractRange & | ) |
GlRenderState::setRange() specialization.
|
protected |
Singular property value for blend mode.
|
protected |
Render value information structures.
|
protected |
Render value unions.
Pointed to by non-texture elements in the render value information array.
|
protected |
Render texture values, contain textures within the array.
|
protected |
Currently attached material.